<include file="public/layout" />
<script type="text/javascript" src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>

<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>拼团订单</h3>
                <h5>商城拼团订单查询及管理</h5>
            </div>
        </div>
    </div>
    <!-- 操作说明 -->
    <div id="explanation" class="explanation" style=" width: 99%; height: 100%;">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span title="收起提示" id="explanationZoom" style="display: block;"></span>
        </div>
        <ul>
            <li>查看操作可以查看拼团成员, 包括拼团成员订单信息等</li>
        </ul>
    </div>
    <div class="flexigrid">
        <div class="mDiv">
            <div class="ftitle">
                <h3>拼团订单列表</h3>
                <h5>(共{$page->totalRows}条记录)</h5>
            </div>
            <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>
            <form class="navbar-form form-inline" method="get" action="{:U('Team/team_order')}" target="_self">
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="30" name="team_id" value="{$Request.param.team_id}" class="qsbox"  placeholder="拼团ID">
                    </div>
                    <div class="sDiv2">
                        <input type="text" size="30" id="start_time" name="start_time" value="{$start_time}" class="qsbox"  placeholder="开团开始时间">
                    </div>
                    <div class="sDiv2">
                        <input type="text" size="30" id="end_time" name="end_time" value="{$end_time}" class="qsbox"  placeholder="开团开始时间">
                    </div>
                    <div class="sDiv2">
                        <select name="status" class="select sDiv3" style="margin-right:5px;margin-left:5px">
                            <option value="">所有拼单</option>
                            <option value="1" <if condition='$Request.param.status eq 1'>selected="selected"</if>>待成团</option>
                            <option value="2" <if condition='$Request.param.status eq 2'>selected="selected"</if>>已成团</option>
                            <option value="3" <if condition='$Request.param.status eq 3'>selected="selected"</if>>未成团</option>
                        </select>
                    </div>
                    <div class="sDiv2">
                        <input type="text" size="30" name="order_sn" class="qsbox" value="{$Request.param.order_sn}" placeholder="拼主订单编号">
                    </div>
                    <div class="sDiv2">
                        <input type="submit" class="btn" value="搜索">
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0">
                    <thead>
                    <tr>
                        <th axis="col0">
                            <div style="width: 24px;"><i class="ico-check"></i></div>
                        </th>
                        <th align="left" axis="col3" class="">
                            <div style="text-align: left; width: 140px;" class="">拼主</div>
                        </th>
                        <th align="center" axis="col5" class="">
                            <div style="text-align: center; width: 200px;" class="">拼团标题</div>
                        </th>
                        <th align="center" axis="col5" class="">
                            <div style="text-align: center; width: 200px;" class="">拼团商品</div>
                        </th>
                        <th align="left" axis="col4" class="">
                            <div style="text-align: center; width: 200px;" class="">订单编号</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 80px;" class="">订单交易状态</div>
                        </th>
                        <th align="center" axis="col6" class="">
                            <div style="text-align: center; width: 80px;" class="">已拼人员</div>
                        </th>
                        <th align="left" axis="col1" class="handle">
                            <div style="text-align: center; width: 150px;">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid">
                <table>
                    <tbody>
                    <empty name="teamFound">
                        <tr data-id="0">
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <i class="fa fa-exclamation-circle"></i>没有符合条件的记录
                            </td>
                        </tr>
                        <else/>
                        <volist name="teamFound" id="found">
                            <tr>
                                <td class="sign" axis="col0">
                                    <div style="width: 24px;"><i class="ico-check"></i></div>
                                </td>
                                <td align="left" axis="col3" class="">
                                    <div style="text-align: left; width: 140px;" class="">{$found[nickname]}</div>
                                </td>
                                <td align="left" axis="col4" class="">
                                    <div style="text-align: center; width: 200px;" class="">
                                        <a class="open" href="{:U('Team/info',['team_id'=>$found[team_id]])}" target="blank">
                                            {$found[team_activity][act_name]}<i class="fa fa-external-link " title="拼团详情"></i>
                                        </a>
                                    </div>
                                </td>
                                <td align="center" axis="col5" class="">
                                    <div style="text-align: center; width: 200px;" class="">
                                        <a class="open" href="{:U('Mobile/Team/info',['goods_id'=>$found[team_activity][goods_id],'item_id'=>$found[team_activity][item_id]])}" target="blank">
                                            {$found[order_goods][goods_name]}<i class="fa fa-external-link " title="手机拼团详情页"></i>
                                        </a>
                                    </div>
                                </td>
                                <td align="center" axis="col6" class="">
                                    <div style="text-align: center; width: 200px;" class="">{$found[order][order_sn]}</div>
                                </td>
                                <td align="center" axis="col6" class="">
                                    <div style="text-align: center; width: 80px;" class="">{$found[order][pay_status_detail]}</div>
                                </td>
                                <td align="center" axis="col6" class="">
                                    <div style="text-align: center; width: 80px;" class="">{$found[join]}人</div>
                                </td>
                                <td align="left" axis="col1" class="handle">
                                    <div style="text-align: left; ">
                                        <if condition="$found[team_activity][team_type] eq 0 OR $found[team_activity][team_type] eq 1">
                                            <if condition="$found[order][order_status] eq 0">
                                                <if condition="$found[Surplus] elt 0">
                                                    <a href="javascript:void(0)" class="btn green confirm_found" data-found-id="{$found[found_id]}"><i class="fa fa-check"></i>确认拼团</a>
                                                    <else/>
                                                    <a class="btn" style="background-color: #D870AD;color: #FFF;box-shadow: none;">还差{$found[Surplus]}人</a>
                                                </if>
                                                <elseif condition="$found[order][order_status] eq 3"/>

                                                <else/>
                                                <a class="btn" style="background-color: #FB6E52;color: #FFF;box-shadow: none;">已确认</a>
                                            </if>
                                        </if>
                                        <if condition="$found[order][order_status] eq 3">
                                            <a class="btn" style="background-color: #FB6E52;color: #FFF;box-shadow: none;">已取消</a>
                                        </if>
                                        <if condition="$found[order][pay_status] eq 1 AND $found[status] eq 3 AND $found[order][order_status] eq 0">
                                            <a href="javascript:void(0)" class="btn red refund_found" data-found-id="{$found[found_id]}"><i class="fa fa-jpy"></i>退款</a>
                                        </if>
                                        <if condition="$found[team_activity][team_type] eq 2">
                                            <if condition="$found[team_activity][is_lottery] eq 1">
                                                <a class="btn belize-hole" href="{:U('Mobile/Team/lottery',['team_id'=>$found[team_id]])}" ><i class="fa fa-play"></i>已开奖</a>
                                                <else/>
                                                <a class="btn belize-hole" href="{:U('Mobile/Team/lottery',['team_id'=>$found[team_id]])}" ><i class="fa fa-pause"></i>等待抽奖</a>
                                            </if>
                                        </if>
                                        <a class="btn green" href="{:U('Team/team_found',['found_id'=>$found[found_id]])}" ><i class="fa fa-list-alt"></i>拼团成员</a>
                                    </div>
                                </td>
                                <td style="width: 100%;">
                                    <div></div>
                                </td>
                            </tr>
                        </volist>
                    </empty>
                    </tbody>
                </table>
                <div class="row">
                    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right">{$page->show()}</div>
                </div>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <!--分页位置-->
    </div>
</div>
<script type="text/javascript">

    $(document).ready(function(){
        $('#start_time').layDate();
        $('#end_time').layDate();
    });

    // 点击刷新数据
    $('.fa-refresh').click(function(){
        location.href = location.href;
    });
    $('.ico-check ' , '.hDivBox').click(function(){
        $('tr' ,'.hDivBox').toggleClass('trSelected' , function(index,currentclass){
            var hasClass = $(this).hasClass('trSelected');
            $('tr' , '#flexigrid').each(function(){
                if(hasClass){
                    $(this).addClass('trSelected');
                }else{
                    $(this).removeClass('trSelected');
                }
            });
        });
    });

    //确认拼团
    $(function () {
        $(document).on("click", '.confirm_found', function (e) {
            var found_id = $(this).data('found-id');
            layer.open({
                content: '确认拼团将把该拼团下的订单都确认，该操作不可逆，确定要执行吗？'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    layer.close(index);
                    $.ajax({
                        type: "POST",
                        url: "{:U('Team/confirmFound')}",//+tab,
                        data: {found_id: found_id},
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 1) {
                                layer.msg(data.msg, {icon: 1, time: 2000}, function(){
                                    window.location.reload();
                                });
                            } else {
                                layer.msg(data.msg, {icon: 2, time: 2000});
                            }
                        }
                    });
                }
                ,btn2: function(index, layero){

                    layer.close(index);
                }
                ,cancel: function(){
                    //右上角关闭回调
                    layer.close();
                }
            });
        })
    })
    //拼团退款
    $(function () {
        $(document).on("click", '.refund_found', function (e) {
            var found_id = $(this).data('found-id');
            layer.open({
                content: '退款将把该拼团下的订单都提交退款至平台，该操作不可逆，确定要执行吗？'
                ,btn: ['确定', '取消']
                ,yes: function(index, layero){
                    layer.close(index);
                    $.ajax({
                        type: "POST",
                        url: "{:U('Team/refundFound')}",//+tab,
                        data: {found_id: found_id},
                        dataType: 'json',
                        success: function (data) {
                            if (data.status == 1) {
                                layer.msg(data.msg, {icon: 1, time: 2000}, function(){
                                    window.location.reload();
                                });
                            } else {
                                layer.msg(data.msg, {icon: 2, time: 2000});
                            }
                        }
                    });
                }
                ,btn2: function(index, layero){
                    layer.close(index);
                }
                ,cancel: function(){
                    //右上角关闭回调
                    layer.close();
                }
            });
        })
    })

</script>
</body>
</html>